# Contributor: Keith Maxwell <keith.maxwell@gmail.com>
# Maintainer: Keith Maxwell <keith.maxwell@gmail.com>
pkgname=ruby-unf_ext
_gemname=unf_ext
pkgver=0.0.9.1
pkgrel=0
pkgdesc="Unicode Normalization Form support library for CRuby"
url="https://github.com/knu/ruby-unf_ext/"
arch="all"
license="MIT"
makedepends="ruby-dev"
checkdepends="ruby-test-unit"
source="https://github.com/knu/ruby-unf_ext/archive/v$pkgver/ruby-unf_ext-$pkgver.tar.gz
	gemspec.patch
	test-helper.patch
	"

build() {
	gem build $_gemname.gemspec

	gem install \
		--local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname

	# Remove unnecessary and duplicated files.
	rm -f dist/extensions/*/*/$_gemname-*/mkmf.log
	cd dist/gems/$_gemname-$pkgver
	rm -rf ext/ lib/*.so README.*
}

check() {
	GEM_PATH='./dist' ruby -Ilib:test:. test/test_unf_ext.rb
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	cd "$builddir"/dist

	mkdir -p "$gemdir"
	cp -r extensions gems specifications "$gemdir"/
}

sha512sums="
ed3bbff1145f8234c88205f00c608d66fabd4986cb328d44526a9e68e925f8534c6eff6b7a002e76b9d6d5092f83622c7bb7bc642df82b629b618fe1008f20c4  ruby-unf_ext-0.0.9.1.tar.gz
54a2b6b9fe507eda737016eda821dbe303ea9178f6c8b0f9c0ec4964eb78ff478a1e9f4289874dc930d49b4dc8faca292f247c7513c481ada669198d08bc24c8  gemspec.patch
fe494139d2d0d4fe183ac2079db90dfffab04736568a8d24e484f6ce0e71326a955e936d516a9f10362dc53706c6a98c408b4afce46fea4325b127f371a6d0c5  test-helper.patch
"
